package com.gopay.common.domain.bank.bcdl;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * 银行定时熔断
 *
 * @author hougn
 * @date 2018-02-01
 */
@Entity
@Table(name = "BIS_TIMING_FUSE")
public class BisTimingFuse implements Serializable {

	public enum TimingStatus {
		UNEXECUTED("0", "未执行"), EXECUTING("1", "执行中"),EXECUTED("2", "已执行") ;

		private String code;
		private String name;

		private TimingStatus(String code, String name) {
			this.name = name;
			this.code = code;
		}

		public String getCode() {
			return code;
		}

		public String getName() {
			return name;
		}

		public static String getNameByCode(String code) {
			if (code == null) {
				return null;
			}
			for (TimingStatus flag : TimingStatus.values()) {
				if (flag.getCode().equals(code)) {
					return flag.name;
				}
			}
			return null;
		}
	}
	public enum DeleteFlag {
		UNDELETE("0", "未删除"), DELETE("1", "已删除");

		private String code;
		private String name;

		private DeleteFlag(String code, String name) {
			this.name = name;
			this.code = code;
		}

		public String getCode() {
			return code;
		}

		public String getName() {
			return name;
		}

		public static String getNameByCode(String code) {
			if (code == null) {
				return null;
			}
			for (DeleteFlag flag : DeleteFlag.values()) {
				if (flag.getCode().equals(code)) {
					return flag.name;
				}
			}
			return null;
		}
	}
	private static final long serialVersionUID = -6240311842289123398L;

	private Long sq;
	/**
	 * 熔断器编号
	 */
	private String sentinelCode;

	/**
	 * 银行代码
	 */
	private String bankCode;

	/**
	 * 开始熔断时间
	 */
	private Date startFusingTs;

	/**
	 * 结束熔断时间
	 */
	private Date endFusingTs;

	/**
	 * 定时熔断任务状态 0：未执行，1：已执行，2：执行中
	 */
	private String timingStatus;

	/**
	 * 创建时间
	 */
	private Date createTs;

	/**
	 * 最新更新时间
	 */
	private Date lastUpdateTs;

	private int version;

	/**
	 * 实际结束时间
	 */
	private Date realEndTs;

	/**
	 * 删除标识
	 */
	private String deleteFlag;

	@Id
	@Column(name = "sq")
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "BIS_TIMING_FUSE_SEQ")
	@SequenceGenerator(name = "BIS_TIMING_FUSE_SEQ", allocationSize = 1, initialValue = 1, sequenceName = "BIS_TIMING_FUSE_SEQ")
	public Long getSq() {
		return sq;
	}

	public void setSq(Long sq) {
		this.sq = sq;
	}

	@Column(name = "sentinel_code")
	public String getSentinelCode() {
		return sentinelCode;
	}

	public void setSentinelCode(String sentinelCode) {
		this.sentinelCode = sentinelCode;
	}

	@Column(name = "bank_code")
	public String getBankCode() {
		return bankCode;
	}

	public void setBankCode(String bankCode) {
		this.bankCode = bankCode;
	}

	@Column(name = "create_ts")
	public Date getCreateTs() {
		return createTs;
	}

	public void setCreateTs(Date createTs) {
		this.createTs = createTs;
	}

	@Column(name = "last_upd_ts")
	public Date getLastUpdateTs() {
		return lastUpdateTs;
	}

	public void setLastUpdateTs(Date lastUpdateTs) {
		this.lastUpdateTs = lastUpdateTs;
	}

	@Version
	@Column(name = "VERSION", nullable = false, precision = 22, scale = 0)
	public int getVersion() {
		return version;
	}

	public void setVersion(int version) {
		this.version = version;
	}

	@Column(name = "end_fusing_ts")
	public Date getEndFusingTs() {
		return endFusingTs;
	}

	public void setEndFusingTs(Date endFusingTs) {
		this.endFusingTs = endFusingTs;
	}

	@Column(name = "start_fusing_ts")
	public Date getStartFusingTs() {
		return startFusingTs;
	}

	public void setStartFusingTs(Date startFusingTs) {
		this.startFusingTs = startFusingTs;
	}

	@Column(name = "timing_status")
	public String getTimingStatus() {
		return timingStatus;
	}

	public void setTimingStatus(String timingStatus) {
		this.timingStatus = timingStatus;
	}

	@Column(name = "REAL_END_TS")
	public Date getRealEndTs() {
		return realEndTs;
	}

	public void setRealEndTs(Date realEndTs) {
		this.realEndTs = realEndTs;
	}

	@Column(name = "DELETE_FLAG")
	public String getDeleteFlag() {
		return deleteFlag;
	}

	public void setDeleteFlag(String deleteFlag) {
		this.deleteFlag = deleteFlag;
	}
}
